<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>给定行和列的和求可行矩阵</title>
</head>
<body>
  <script>
    function fn(rowSum, colSum) {
      let arr = new Array()
      for (let i = 0; i < rowSum.length; i++) {
        arr[i] = new Array()
        for (let j = 0; j < colSum.length; j++) {
          let min = Math.min(rowSum[i], colSum[j])
          arr[i][j] = min
          rowSum[i] -= min
          colSum[j] -= min
        }
      }
      return arr
    }
    console.log(fn([3, 8], [4, 7]))
  </script>
</body>
</html>